package com.yvtian.om.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yvtian.om.pojo.OmCustomerEntity;
import com.yvtian.om.dao.OmCustomerMapper;
import com.yvtian.om.service.OmCustomerService;
import com.yvtian.utils.StringHelper;
import org.springframework.stereotype.Service;

/**
 * (om_customer)表服务实现类
 *
 * @author long
 * @since 2024-05-08 09:37:29
 */
@Service("omCustomerService")
public class OmCustomerServiceImpl extends ServiceImpl<OmCustomerMapper, OmCustomerEntity> implements OmCustomerService {

    @Override
    public IPage<OmCustomerEntity> findByPage(Page<OmCustomerEntity> page, OmCustomerEntity omCustomerEntity) {
        LambdaQueryWrapper<OmCustomerEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(OmCustomerEntity::getIsDel,0);
        if (omCustomerEntity.getId() != null){
            queryWrapper.eq(OmCustomerEntity::getId,omCustomerEntity.getId());
        }
        if (StringHelper.isNotEmpty(omCustomerEntity.getCode())){
            queryWrapper.like(OmCustomerEntity::getCode,omCustomerEntity.getCode());
        }
        if (StringHelper.isNotEmpty(omCustomerEntity.getName())){
            queryWrapper.like(OmCustomerEntity::getName,omCustomerEntity.getName());
        }
        if (StringHelper.isNotEmpty(omCustomerEntity.getWContacts())){
            queryWrapper.like(OmCustomerEntity::getWContacts,omCustomerEntity.getWContacts());
        }
        return this.page(page, queryWrapper);
    }
}

